package com.cloud.drore.eboss.supplier.controller;

import com.cloud.drore.eboos.common.base.ResultMessage;
import com.cloud.drore.eboss.operation.entity.Demo;
import com.cloud.drore.eboss.operation.service.impl.DemoServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 浙江卓锐科技股份有限公司 版权所有 © Copyright 2018<br>
 * @Description: SupplierSettlementTable<br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2017/12/29 11:23 <br>
 * @Author: <a href="836327318@qq.com">夏凯</a>
 */
@RestController
@RequestMapping("/SupplierSettlementTable")
@Api(value = "/供应商", description = "供应商-杨亮")
public class SupplierSettlementTableController {

    @Resource
    DemoServiceImpl demoService;


    @ApiOperation(value = "保存信息")
    @PostMapping(value = "/save")
    public ResultMessage<Demo> save(@RequestBody @Validated({Demo.SAVE.class})  Demo demo){
        return new ResultMessage(demoService.insert(demo));
    }

    @ApiOperation(value = "更新信息")
    @PutMapping(value = "/update")
    public ResultMessage<Demo> update(@RequestBody @Valid Demo demo){
        return new ResultMessage(demoService.updateByPrimaryKey(demo));
    }

    @ApiOperation(value = "删除信息")
    @DeleteMapping(value = "/delete/{id}")
    public ResultMessage<Demo> delete(@PathVariable("id") Long id){
        return new ResultMessage(demoService.deleteByPrimaryKey(id));
    }

    @ApiOperation(value = "供应商结算时候调用的接口")
    @GetMapping(value = "/{id}")
    public ResultMessage<Demo> get(@PathVariable("id") Long id){
        return new ResultMessage(demoService.selectByPrimaryKey(id));
    }


}
